<?php
class ModelUserQuestion extends Model {

    public function addQuestion($data){

        $this->db->query("INSERT INTO " . DB_PREFIX . "question SET name = '" . $this->db->escape($data['name']) . "',  url = '" . $this->db->escape($data['url']) . "',date_added = now() ");
    }

    public function editQuestion($question_id, $data) {
        $this->db->query("UPDATE " . DB_PREFIX . "question SET name = '" . $this->db->escape($data['name']) . "',  url = '" . $this->db->escape($data['url']) . "'  WHERE question_id = '" . (int)$question_id . "'");
    }



    public function getQuestion($question_id) {
        $query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "question WHERE question_id = '" . (int)$question_id . "'");

        return $query->row;
    }

    public function getQuestions() {
        $sql = "SELECT * FROM " . DB_PREFIX . "question";

        $query = $this->db->query($sql);

        return $query->rows;
    }

    public function deleteQuestion($question_id){
       $this->db->query("DELETE  FROM " . DB_PREFIX . "question WHERE question_id = '" . (int)$question_id . "'");
    }
}